package com.woniuxy.yygh.hsop.controller;

import com.woniuxy.yygh.common.result.Result;
import com.woniuxy.yygh.hsop.service.HospitalService;
import com.woniuxy.yygh.hsop.service.HospitalSetService;
import com.woniuxy.yygh.model.hosp.Hospital;
import com.woniuxy.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: 对mongdb中医院controller
 * <P> Date: 2022/3/2:9:03
 * <P> Description:
 */
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    /**
     * TODO: 根据医院id查询医院详情信息
     **/
    @ApiOperation(value = "根据id医院详情信息")
    @GetMapping("/showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id) {
        Map<String, Object> map = hospitalService.getHospById(id);
        return Result.ok(map);
    }

    /**
     * TODO:更新医院上线状态 根据医院id更改status
     **/
    @ApiOperation(value = "更新医院上线状态")
    @PutMapping("/updateHospitalStatus/{id}/{status}")
    public Result updateHospitalStatus(@PathVariable String id,
                                       @PathVariable Integer status) {
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    /**
     * TODO:查询医院列表 并且分页
        实体可以根据省 市 区 和医院名字来查询
     **/
    @ApiOperation(value = "查询医院列表")
    @GetMapping("/list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page,
                           @PathVariable Integer limit,
                           HospitalQueryVo hospitalQueryVo) {

        Page<Hospital> hospPages = hospitalService.selectHospPage(page, limit, hospitalQueryVo);

        return Result.ok(hospPages);

    }

}
